home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / subs.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  162 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. WRITE_HANDLER( subs_invert1_w )
  13. {
  14.     if ((offset & 0x01) == 1)
  15.     {
  16.         palette_change_color(0, 0x00, 0x00, 0x00);
  17.         palette_change_color(1, 0xFF, 0xFF, 0xFF);
  18.     }
  19.     else
  20.     {
  21.         palette_change_color(1, 0x00, 0x00, 0x00);
  22.         palette_change_color(0, 0xFF, 0xFF, 0xFF);
  23.     }
  24. }
  25.  
  26. WRITE_HANDLER( subs_invert2_w )
  27. {
  28.     if ((offset & 0x01) == 1)
  29.     {
  30.         palette_change_color(2, 0x00, 0x00, 0x00);
  31.         palette_change_color(3, 0xFF, 0xFF, 0xFF);
  32.     }
  33.     else
  34.     {
  35.         palette_change_color(3, 0x00, 0x00, 0x00);
  36.         palette_change_color(2, 0xFF, 0xFF, 0xFF);
  37.     }
  38. }
  39.  
  40.  
  41. /***************************************************************************
  42.  
  43.   Draw the game screen in the given osd_bitmap.
  44.   Do NOT call osd_update_display() from this function, it will be called by
  45.   the main emulation engine.
  46.  
  47. ***************************************************************************/
  48. void subs_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  49. {
  50.     int offs;
  51.  
  52.     if (palette_recalc())
  53.         memset(dirtybuffer,1,videoram_size);
  54.  
  55.     /* for every character in the Video RAM, check if it has been modified */
  56.     /* since last time and update it accordingly. */
  57.     for (offs = videoram_size - 1;offs >= 0;offs--)
  58.     {
  59.         if (full_refresh || dirtybuffer[offs])
  60.         {
  61.             int charcode;
  62.             int sx,sy;
  63.             int left_enable,right_enable;
  64.             int left_sonar_window,right_sonar_window;
  65.  
  66.             left_sonar_window = 0;
  67.             right_sonar_window = 0;
  68.  
  69.             dirtybuffer[offs]=0;
  70.  
  71.             charcode = videoram[offs];
  72.  
  73.             /* Which monitor is this for? */
  74.             right_enable = charcode & 0x40;
  75.             left_enable = charcode & 0x80;
  76.  
  77.             sx = 8 * (offs % 32);
  78.             sy = 8 * (offs / 32);
  79.  
  80.             /* Special hardware logic for sonar windows */
  81.             if ((sy >= (128+64)) && (sx < 32))
  82.                 left_sonar_window = 1;
  83.             else if ((sy >= (128+64)) && (sx >= (128+64+32)))
  84.                 right_sonar_window = 1;
  85.             else
  86.                 charcode = charcode & 0x3F;
  87.  
  88.             /* Draw the left screen */
  89.             if ((left_enable || left_sonar_window) && (!right_sonar_window))
  90.             {
  91.                 drawgfx(tmpbitmap,Machine->gfx[0],
  92.                         charcode, 1,
  93.                         0,0,sx,sy,
  94.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  95.             }
  96.             else
  97.             {
  98.                 drawgfx(tmpbitmap,Machine->gfx[0],
  99.                         0, 1,
  100.                         0,0,sx,sy,
  101.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  102.             }
  103.  
  104.             /* Draw the right screen */
  105.             if ((right_enable || right_sonar_window) && (!left_sonar_window))
  106.             {
  107.                 drawgfx(tmpbitmap,Machine->gfx[0],
  108.                         charcode, 0,
  109.                         0,0,sx+256,sy,
  110.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  111.             }
  112.             else
  113.             {
  114.                 drawgfx(tmpbitmap,Machine->gfx[0],
  115.                         0, 0,
  116.                         0,0,sx+256,sy,
  117.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  118.             }
  119.         }
  120.     }
  121.  
  122.     /* copy the character mapped graphics */
  123.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  124.  
  125.     /* draw the motion objects */
  126.     for (offs = 0; offs < 4; offs++)
  127.     {
  128.         int sx,sy;
  129.         int charcode;
  130.         int prom_set;
  131.         int sub_enable;
  132.  
  133.         sx = spriteram[0x00 + (offs * 2)] - 16;
  134.         sy = spriteram[0x08 + (offs * 2)] - 16;
  135.         charcode = spriteram[0x09 + (offs * 2)];
  136.         sub_enable = spriteram[0x01 + (offs * 2)];
  137.  
  138.         prom_set = charcode & 0x01;
  139.         charcode = (charcode >> 3) & 0x1F;
  140.  
  141.         /* Left screen - special check for drawing right screen's sub */
  142.         if ((offs!=0) || (sub_enable))
  143.         {
  144.             drawgfx(bitmap,Machine->gfx[1],
  145.                     charcode + 32 * prom_set,
  146.                     0,
  147.                     0,0,sx,sy,
  148.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  149.         }
  150.  
  151.         /* Right screen - special check for drawing left screen's sub */
  152.         if ((offs!=1) || (sub_enable))
  153.         {
  154.             drawgfx(bitmap,Machine->gfx[1],
  155.                     charcode + 32 * prom_set,
  156.                     0,
  157.                     0,0,sx + 256,sy,
  158.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  159.         }
  160.     }
  161. }
  162.